/***********************************************************************
 *
 * MODULE NAME:    host_buf.h
 * DESCRIPTION:    Host System buffers
 * MAINTAINER:     Dave Airlie
 *
 * SOURCE CONTROL: $Id: host_buf.h,v 1.5 2009/01/09 08:35:28 lugongyu Exp $
 *
 * LICENSE:
 *     This source code is copyright (c) 2000 RDA Microelectronics.
 *     All rights reserved.
 *
 ***********************************************************************/
#ifndef RDABT_HOST_BUF_H
#define RDABT_HOST_BUF_H


#include "host_config.h"
#include "bt_types.h"

typedef struct st_rdabt_host_buf_t rdabt_host_buf_t;

struct st_rdabt_host_buf_t 
{
	/*IMPORTANT:
		The first four members of the structure should be data, transport, len, and totalsize
		in that order. The user-level struct st_t_dataBuf with only these members present.  */
    u_int8 *data;
    u_int8 transport;
    u_int16 len;

    u_int16 totalsize;
    u_int16 flags; 
    u_int16 hci_handle_flags;
#if COMBINED_HOST==1
    void *qd;
#endif    
#if pDEBUG==1    
    /* the head and tail is for check bound when reserve/release header */
    u_int8 *head;
    u_int8 *tail;
#endif

#if L2CAP_FRAGMENT_ACL_SUPPORT==1
    /* linked list ability - flow control can use this */
    rdabt_host_buf_t *next;

    /* parent buffer and child counter */
    rdabt_host_buf_t *parent;
    u_int16 child_count;
#endif  
};


/* Functions */
rdabt_host_buf_t * host_buf_alloc(u_int32 size);
rdabt_host_buf_t * host_buf_child_alloc(rdabt_host_buf_t *parent, u_int8 *new_data, u_int32 length);
void host_buf_free(rdabt_host_buf_t *buf);
t_api host_buf_reserve_header(rdabt_host_buf_t *buf, u_int32 size);
t_api host_buf_release_header(rdabt_host_buf_t *buf, u_int32 size);

#if COMBINED_HOST==1
/* copy data to a2dp queue */
t_api host_buf_CopyToA2dpBuffer(rdabt_host_buf_t *p_buf);
#endif  

#endif

